﻿using eShop.Core;
using eShop.Web.Framework;
using System.Web.Mvc;
using System.Web.Routing;

namespace eShop.Web.Controllers
{
    /// <summary>
    /// 首页控制器类
    /// </summary>
    public partial class HomeController : BaseWebController
    {


        public ActionResult Regsoftware()
        {
            string regCode = WebHelper.GetQueryString("regcode");
            string machineCode = RSApublic.GetMachineCode();

            //判断验证码是否正确
            string[] matchArray = regCode.Split('|');
            string datetimeStr = matchArray[1].ToString();
            string decodeDateTimeStr = ZEncypt.DESDecrypt(datetimeStr);
            //验证字符串
            string validStr = machineCode + "|" + decodeDateTimeStr;
            //
            string signStr = matchArray[0];// RSA.SignData(validStr);
            ConfigHelper.SetValue("SN", regCode);
            if (RSApublic.varifySign(signStr, validStr))
                return AjaxResult("message", "注册成功");
            else
                return AjaxResult("message", "注册失败");

        }
        /// <summary>
        /// 首页
        /// </summary>
        public ActionResult Index()
        {
            //判断请求是否来自移动设备，如果是则重定向到移动主题
            if (WebHelper.GetQueryInt("m") != 1 && WebHelper.IsMobile())
                return RedirectToAction("index", "home", new RouteValueDictionary { { "area", "mob" } });
            //首页的数据需要在其视图文件中直接调用，所以此处不再需要视图模型
            return View();
        }
    }
}
